<?php 
$ref="W".date("siHdmY");

if(!getParameter("objectName") && !getParameter("objectId")) {
?>


<div id="objectnametdiv">
<input type="text" id="objectname" size="100"  class="ui-autocomplete-input ui-corner-all" autocomplete="on" value=""/>
<input type="text" id="ButterflyPortal_data_OBJECTNAME" name="ButterflyPortal_data_OBJECTNAME" value=""/>
</div>


<div id="objectiddiv">
<input type="text" id="objectid" size="100"  class="ui-autocomplete-input ui-corner-all" autocomplete="on" value=""/>
<input type="hidden" id="ButterflyPortal_data_OBJECTID" name="ButterflyPortal_data_OBJECTID" value=""/>
</div>
<script type="text/javascript">




$(function() {

	 
    $( "#objectname" ).autocomplete({
      minLength: 0,
      source: '/portlet.php?app=system&operation=getportalobjects&objectname=<?=getObjByKey("portal_objects","id","name","portal_objects")?>',
     
      select: function( event, ui ) {
        $( "#objectname" ).val( ui.item.label );
        $( "#ButterflyPortal_data_OBJECTNAME" ).val( ui.item.value );
    	prepareautocomplete();
        return false;
      }
    })
  
  });




function prepareautocomplete(){
  $(function() {


    $( "#objectid" ).autocomplete({
      minLength: 0,
      source: '/portlet.php?app=system&operation=getportalobjects&objectname='+$("#ButterflyPortal_data_OBJECTNAME").val(),
     
      select: function( event, ui ) {
        $( "#objectid" ).val( ui.item.label );
        $( "#ButterflyPortal_data_OBJECTID" ).val( ui.item.value );
 
        return false;
      }
    })
  
  });
}

$("#el_OBJECTID").html($("#objectiddiv"));

$("#el_OBJECTNAME").html($("#objectnametdiv"));
</script>

<?php }?>
